package mest.util;

import mest.entity.User;

import java.lang.reflect.Field;

public class ObjectUtil {


    /**
     * 校验某对象是否存在某属性
     *
     * @param obj
     * @param filed
     * @return
     */
    public static boolean contains(Object obj, String filed) {
        Class cls = obj.getClass();
        String filedName = filed;
        Field[] fields = cls.getDeclaredFields();
        boolean flag = false;
        for (int i = 0; i < fields.length; i++) {
            if (fields[i].getName().equals(filedName)) {
                flag = true;
                break;
            }
        }
        return flag;
    }


    public static void main(String[] args) {

    }


}
